import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_app1/listData.dart';

class SwiperPage extends StatefulWidget {
  @override
  _SwiperPageState createState() => _SwiperPageState();
}

class _SwiperPageState extends State<SwiperPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Swiper'),
      ),
      body: Column(
        children: <Widget>[
          AspectRatio(
            aspectRatio: 16/9, // 宽高比
            child: new Swiper(
              itemBuilder: (BuildContext context,int index){
                return Container(
                  margin: EdgeInsets.only(top: 20),
                  child: ClipRRect(
                    child: new Image.network(tempData[index]['imageUrl'],fit: BoxFit.fill,),
                    borderRadius: BorderRadius.circular(10),
                  ),
                );
              },
              itemCount: tempData.length,
              pagination: new SwiperPagination(),
              viewportFraction: 0.8,
              scale: 0.9,
//              control: new SwiperControl(), // 左右箭头
            ),
          )
        ],
      ),
    );
  }
}
